package com.gnerv.rabbitmq.agent.command;

import com.gnerv.rabbitmq.agent.model.entity.Node;
import com.gnerv.rabbitmq.agent.tools.ExecTools;
import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author Gnerv LiGen
 */
public class ShovelCommand extends AbstractRabbitmqctlCommand {

    public ShovelCommand(Node node) {
        super();
        setNode(node);
    }

    public static ShovelCommand build(Node node) {
        return new ShovelCommand(node);
    }

    public ExecTools.ExecResult addShovel(String name, String value) {
        List<String> listExchanges = Lists.newArrayList();
        listExchanges.add("set_parameter");
        listExchanges.add("shovel");
        listExchanges.add(name);
        listExchanges.add(value);
        return run(listExchanges);
    }

    public ExecTools.ExecResult shovelStatus() {
        List<String> listExchanges = Lists.newArrayList();
        listExchanges.add("shovel_status");
        return run(listExchanges);
    }

    public ExecTools.ExecResult deleteShovel(String vhost, String name) {
        List<String> listExchanges = Lists.newArrayList();
        listExchanges.add("delete_shovel");
        listExchanges.add("-p");
        listExchanges.add(vhost);
        listExchanges.add(name);
        return run(listExchanges);
    }

}
